import java.util.*
import java.io.*

fun main() {
    val file1 = File("data.txt")
    val file2 = File("data.js")
    val bufferedReader = file1.bufferedReader(Charsets.UTF_8, DEFAULT_BUFFER_SIZE)
    val writer = file2.writer(Charsets.UTF_8)
    var line: String

    try {
        while (true) {
            line = bufferedReader.readLine() ?: break;
            var duan = "断镜云: ";
            if(line.indexOf(duan) > 0) {
                var lines = line.split(duan)
                if(lines.size == 2) {
                    println(lines.get(0) + "\n" + duan + lines.get(1) + "\n")
                    writer.write(lines.get(0) + "\n" + duan + lines.get(1) + "\n");
                }else {
                    println(line)
                    writer.write(line.trim() + "\n");
                }
            }else {
                println(line)
                writer.write(line.trim() + "\n");
            }
        }
    } catch (e: Exception) {
        e.printStackTrace()
    } finally {
        try {
            bufferedReader.close()
            writer.close();
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
    // println(Ju.JIA_ZII_YIN.getA());
    // println(Ju.甲子_寅.getA());
    // val s1: String
    // val s2: String
    // val sc = Scanner(System.`in`)
    // print("请输入第一个字符串：")
    // s1 = sc.nextLine()
    // print("请输入第二个字符串：")
    // s2 = sc.next()
    // println("输入的字符串是：$s1.$s2")
}